using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;

public class AudioManager : MonoBehaviour
{
    public static AudioManager Instance { get; private set; }

    [SerializeField] private AudioClip birdCollison;
    [SerializeField] private AudioClip birdSelect;
    [SerializeField] private AudioClip birdFlying;
    [SerializeField] private AudioClip[] pigCollisons;
    [SerializeField] private AudioClip woodCollision;
    [SerializeField] private AudioClip woodDestoryed;

    private void Awake()
    {
        Instance = this;
    }

    public void PlayBirdCollision(Vector3 position)
    {
        AudioSource.PlayClipAtPoint(birdCollison, position, 1f);
    }
    
    public void PlayBirdSelect(Vector3 position)
    {
        AudioSource.PlayClipAtPoint(birdSelect, position, 1f);
    }
    
    public void PlayBirdFlying(Vector3 position)
    {
        AudioSource.PlayClipAtPoint(birdFlying, position, 1f);
    }

    public void PlayPigCollision(Vector3 position)
    {
        int randomIndex = Random.Range(0, pigCollisons.Length);
        AudioClip ac = pigCollisons[randomIndex];
        AudioSource.PlayClipAtPoint(ac, position, 1f);
    }
    
    public void PlayWoodCollision(Vector3 position)
    {
        AudioSource.PlayClipAtPoint(woodCollision, position, .3f);
    }

    public void PlayWoodDestroyed(Vector3 position)
    {
        AudioSource.PlayClipAtPoint(woodDestoryed, position, .2f);
    }
}
